<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body table {
	text-align: center;
}
</style>
</head>

<body>




<table width="449" border="2">
  <tr>
    <td width="27">STT</td>
    <td width="65">Tên Hàng</td>
    <td width="103">Số lượng hiện có</td>
    <td width="97">Số lượng mua</td>
    <td width="53">Đơn giá</td>
    <td width="62">Chọn mua</td>
  </tr>
  <tr>
    <td>1</td>
    <td>CPU</td>
    <td>10</td>
    <td><input type="text" id="chon1" disabled="disabled" onchange="a()" value="0" /></td>
    <td>100</td>
    <td><input type="checkbox" onchange="t1()" /></td>
  </tr>
  <tr>
    <td>2</td>
    <td>RAM</td>
    <td>10</td>
    <td><input type="text" id="chon2" disabled="disabled" onchange="b()" value="0" /></td>
    <td>50</td>
    <td><input type="checkbox" onchange="t2()" /></td>
  </tr>
  <tr>
    <td>3</td>
    <td>HDD</td>
    <td>10</td>
    <td><input type="text" id="chon3" disabled="disabled" onchange="c()" value="0"/></td>
    <td>80</td>
    <td><input type="checkbox" onchange="t3()" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="left"><input type="button" value="OK" onclick="ok()" /></td>
    <td colspan="3" align="right">Tổng: <input type="text" id="tong" readonly="readonly" /></td>
    <td><input type="checkbox" onchange="t()" onclick="vat()"/>VAT</td>
  </tr>
</table>

<script type="text/javascript">
	function t1(){
				document.getElementById("chon1").disabled=false;
	}
	function t2(){
				document.getElementById("chon2").disabled=false;
	}
	function t3(){
				document.getElementById("chon3").disabled=false;
	}
	function a(){
	if(document.getElementById("chon1").value > 10)
	alert("phải nhỏ hơn 10");
	}
	function b(){
	if(document.getElementById("chon2").value > 10)
	alert("phải nhỏ hơn 10");
	}
	function c(){
	if(document.getElementById("chon3").value > 10)
	alert("phải nhỏ hơn 10");
	}
	function ok(){
	document.getElementById("tong").value= parseFloat(document.getElementById("chon1").value)*100+ parseFloat(document.getElementById("chon2").value)*50 + parseFloat(document.getElementById("chon3").value)*80;
	}
	function vat(){
	document.getElementById("tong").value=parseFloat(document.getElementById("tong").value)*110/100;
	}
</script>
</body>
</html>
